

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <style type="text/css">
      td {
        font-family: arial; font-size: 11px; text-align: center
      }
      td.dt {
        font-family: arial; font-size: 11px; text-align: center
      }
      a {
        color: blue
      }
      a:hover {
        color: red
      }
      a.bt {
        color: #888888
      }
    </style>
    <script language="javascript">
      var str='',i,j,yy,mm,openbound,callback;
      var fld1,fld2;
      var arrDate;
      var flg;
      var wp=window.parent;
      var cf=wp.document.getElementById("CalFrame");
      var fld,curday,today=new Date();
      today.setHours(0);today.setMinutes(0);today.setSeconds(0);today.setMilliseconds(0);
      function parseDate(s) {
      	var reg=new RegExp("[^0-9-]","")
      	if(s.search(reg)>=0)return today;
      	var ss=s.split("-");
      	if(ss.length!=3)return today;
      	if(isNaN(ss[0])||isNaN(ss[1])||isNaN(ss[2]))return today;
      	return new Date(parseFloat(ss[0]),parseFloat(ss[1])-1,parseFloat(ss[2]));
      }
      function resizeCalendar(){
        cf.width=180;cf.height=220;
      }
      function initCalendar() {
      	if(fld1&&fld1.value.length>0) {
      	  curday=parseDate(fld1.value);
      	}
      	else if(fld2&&fld2.value.length>0){
      	  curday=parseDate(fld2.value);
      	}
      	else 
      	  curday=today;
      	drawCalendar(curday.getFullYear(),curday.getMonth());
      }
      function drawCalendar(y,m) {
      	var x=new Date(y,m,1),mv=x.getDay(),d=x.getDate(),de;
      	yy=x.getFullYear();mm=x.getMonth();
      	document.getElementById("y").value=yy;
      	document.getElementById("m").value=mm+1;
      	for(var i=1;i<=mv;i++) {
      	  de=document.getElementById("d"+i);
      	  de.innerHTML="";
      	  de.bgColor="";
      	}
      	while(x.getMonth()==mm) {
	      de=document.getElementById("d"+(d+mv));
	      
	      if(x.getTime()==curday.getTime())
	        de.bgColor="#dddddd";
	      else
	        de.bgColor="white";

	      if (arrDate==null || arrDate=="undefined" || arrDate=="" || arrDate.length==0) {
	        if(x.getTime()==today.getTime())
	          de.innerHTML="<a href=javascript:setDate("+d+");><font color=red>"+d+"</font></a>";
	        else if(x.getTime()<today.getTime())
	          if(openbound){
	            de.innerHTML="<a href=javascript:setDate("+d+"); class=bt>"+d+"</a>";
	          }
	          else{
	            de.innerHTML="<font color=#888888>"+d+"</font>";
	          }
	        else
	          de.innerHTML="<a href=javascript:setDate("+d+");>"+d+"</a>";
	      }  
	      else { if (flg != "1") {
	         for (var i=0; i<arrDate.length; i++) {
	           if (x.getTime()==parseDate(arrDate[i]).getTime()) {
	             if(x.getTime()==today.getTime())
	               de.innerHTML="<a href=javascript:setDate("+d+");><font color=red>"+d+"</font></a>";
	        	 else if(x.getTime()<today.getTime())
	               if(openbound){
	                 de.innerHTML="<a href=javascript:setDate("+d+");>"+d+"</a>";
	               }
	               else{
	                 de.innerHTML="<font color=#888888>"+d+"</font>";
	               }
	             else
	               de.innerHTML="<a href=javascript:setDate("+d+");>"+d+"</a>";
	             break;
	           }
	           else {
	             de.innerHTML="<font color=#888888>"+d+"</font>";
	           }
	         } } else {
	           if (x.getTime()< parseDate(arrDate[0]).getTime() || x.getTime()> parseDate(arrDate[1]).getTime()) {
	           	de.innerHTML="<font color=#888888>"+d+"</font>";
	           } else {
		        if(x.getTime()==today.getTime())
		          de.innerHTML="<a href=javascript:setDate("+d+");><font color=red>"+d+"</font></a>";
		        else if(x.getTime()<today.getTime())
		          if(openbound){
		            de.innerHTML="<a href=javascript:setDate("+d+"); class=bt>"+d+"</a>";
		          }
		          else{
		            de.innerHTML="<font color=#888888>"+d+"</font>";
		          }
		        else
		          de.innerHTML="<a href=javascript:setDate("+d+");>"+d+"</a>";
	           }
	         }
	      }  

	      x.setDate(++d);
      	}
      	while(d+mv<=42) {
      	  de=document.getElementById("d"+(d+mv));
      	  de.innerHTML="";
      	  de.bgColor="";
      	  d++;
      	}
      }
      function setDate(d) {
      	wp.hideCalendar();
      	if(mm+1 > 9){
      	  if (d>9)
      	    var dstr=yy+"-"+(mm+1)+"-"+d;
      	  else
      	    var dstr=yy+"-"+(mm+1)+"-0"+d;
      	}else{
      	  if (d>9)
      	    var dstr=yy+"-0"+(mm+1)+"-"+d;
      	  else
      	    var dstr=yy+"-0"+(mm+1)+"-0"+d;
      	}
      	if(callback&&callback.length>0) {
      	  eval("wp."+callback+"(\""+dstr+"\")");
      	}
      	else{
      	  fld1.value=dstr;
      	}
      }
    </script>
  </head>
  <body leftmargin="0" topmargin="0" onload="resizeCalendar();" marginheight="0" marginwidth="0">
    <table bgcolor="#336699" border="0" cellpadding="1" cellspacing="0" id="tbl0" width="100%">
      <tr>
        <td>
          <table bgcolor="white" border="0" cellpadding="2" cellspacing="1" width="100%">
            <tr bgcolor="#72b1ff">
              <td id="prev" width="16">
              	<a href="javascript:drawCalendar(yy,mm-1);"><img border="0" height="16" src="prev.gif" width="16"></a>
              </td>
              <td style="color: white; font-size: 11px" width="178">
                <select id="y" onchange="drawCalendar(this.value,mm);">
                  <script language="javascript">
                    str="";
	                for(i=2099;i>1929;i--) {
	                  str+="<option value="+i+">"+i+"</option>";
	                }
	                document.write(str);
	              </script>
	            </select>年
	            <select id='m' onchange="drawCalendar(yy,this.value-1);">
	              <script language="javascript">
	                str="";
	                for(i=1;i<13;i++) {
	                  str+="<option value="+i+">"+i+"</option>";
	                }
	                document.write(str);
                  </script>
                </select>月
              </td>
              <td id="next" width="16">
              	<a href="javascript:drawCalendar(yy,mm+1);"><img border="0" height="16" src="next.gif" width="16"></a>
              </td>
            </tr>
          </table>
          <table bgcolor="white" border="0" cellpadding="0" cellspacing="4" width="178">
            <tr height="18">
              <td width="18"><font color="red">日</font></td>
              <td width="18">一</TD>
              <td width="18">二</TD>
              <td width="18">三</TD>
              <td width="18">四</TD>
              <td width="18">五</TD>
              <td width="18"><font color="red">六</font></td>
            </tr>
            <tr height="1">
              <td bgcolor="gray" colspan=7></td>
            </tr>
    	    <script language="javascript">
    	      str="";
	          for(i=0;i<6;i++) {
	    	    str+="<tr height=18>";
	    	    for(j=1;j<=7;j++) {
	    	      str+="<td id=d"+(i*7+j)+" class=dt></td>";
	    	    }
	    	    str+="</tr>";
	          }
	          document.write(str);
            </script>
            <tr height="1">
              <td bgcolor="gray" colspan="7"></td>
            </tr>
            <tr height="18" >
              <td colspan="3" align="center"><a href="#"><span onclick="javascript:wp.hideCalendar();fld1.value='';">清除</span></a></td>
              <td colspan="1"></td>
              <td colspan="3" align="center"><a href="#"><span onclick="javascript:wp.hideCalendar();">关闭</span></a></td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
    <script language="javascript">
      var bCalLoaded=true;
    </script>
  </body>
</html>
